package LeetCode.day2;

import java.util.*;

/**
 * @description:
 * @author: Cter
 * @date: 2020/6/28
 */
public class Solution {
    public int minSubArrayLen(int s, int[] nums) {


        List<Integer> list = new ArrayList<>();
        for (int i=0;i<nums.length;i++){
            int temp = 1;
            int num = 0;
            num = num+nums[i];
            if (num>=s){
                list.add(1);
            }
            for (int j=i+1;j<nums.length;j++){
                temp++;
                num = num +  nums[j];
                if (num>=s){
                    list.add(temp);
                }
            }
        }
        if (list.size()<=0){
            return 0;
        }

        Integer small= nums.length;
        for (Integer integer :list){
            if (integer<small){
                small = integer;
            }
        }
        return small;
    }

    public static void main(String[] args) {
        Solution solution = new Solution();
        int[] a = {5,1,3,5,10,7,4,9,2,8};
        System.out.println(solution.minSubArrayLen(15,a));

    }
}
